<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者，助力中小企业发展 
+----------------------------------------------------------------------
| Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
+----------------------------------------------------------------------
| 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
+----------------------------------------------------------------------
| 组件-工具菜单 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->

<template>
	<view class="component-menu-tool">
		<block v-for="(item, index) in showData" :key="index">
			<view class="tool-item" @click="toPage(item.info)" v-if="item.info != 'contact'">
				<view class="item-icon" :style="{width: iconWidth, height: iconWidth}">
					<view class="icon" :style="{backgroundImage: 'url('+ item.icon +')', backgroundSize: iconWidth}" v-if="item.icon"></view>
				</view>
				<view class="item-info">
					<view class="info-text" :style="{fontSize: fontSize}">{{item.text}}</view>
					<view class="info-count" v-if="item.count > 0">{{item.count}}</view>
				</view>
				<view class="item-more">
					<image class="icon" src="/static/right.png" mode="aspectFit"></image>
				</view>
			</view>
			<!-- #ifdef MP-WEIXIN -->
			<button class="tool-item" open-type="contact" v-else>
				<view class="item-icon" :style="{width: iconWidth, height: iconWidth}">
					<view class="icon" :style="{backgroundImage: 'url('+ item.icon +')', backgroundSize: iconWidth}" v-if="item.icon"></view>
				</view>
				<view class="item-info">
					<view class="info-text" :style="{fontSize: fontSize}">{{item.text}}</view>
					<view class="info-count" v-if="item.count > 0">{{item.count}}</view>
				</view>
				<view class="item-more">
					<image class="icon" src="/static/right.png" mode="aspectFit"></image>
				</view>
			</button>
			<!-- #endif -->
		</block>
	</view>
</template>

<script>
	export default {
		name: "componentMenuTool",
		props: {
			showData: {
				type: Array,
				default () {
					return []
				}
			},
			iconWidth: {
				type: String,
				default: "56rpx"
			},
			fontSize: {
				type: String,
				default: "28rpx"
			},
		},
		methods: {
			// 跳转页面
			toPage(e) {
				this.$util.toPage(e)
			}
		},
	}
</script>

<style lang="scss">
	.component-menu-tool {
		.tool-item {
			padding: 24rpx 0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: transparent;

			.item-icon {
				.icon {
					width: 100%;
					height: 100%;
				}
			}

			.item-info {
				flex: 1;
				display: flex;
				align-items: center;

				.info-text {
					line-height: 1.4;
					font-weight: 600;
					margin-left: 32rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					word-break: break-all;
					color: #242629;
				}
			}

			.item-more {
				width: 24rpx;
				height: 24rpx;
				margin-left: 24rpx;

				.icon {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
</style>